<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文章列表</title>
<link
	href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css"
	rel="stylesheet">
<style type="text/css">
body {
  font: 13px/20px 'Lucida Grande', Tahoma, Verdana, sans-serif;
  color: #404040;
  background: #0ca3d2;
}

</style>
</head>
<script type="text/javascript" src="./js/index.js"></script>
<body>
	<h1>文章列表 </h1>
	<ul>
		<c:forEach var="t" items="${articles}">
			<li>
				<h3>标题：${t.title}</h3>
				<p>内容：${t.content}</p>
				<p>时间和日期：${t.publishDate}</p>
				<p><a href="./del.do?id=${t.id}">删除</a></p>
			</li>
		</c:forEach>
	</ul>
	<ul class="pagination">
			<li  class="${currentPage == 0 ? 'disabled' : ''}">
				<a href="./list.do?page=${currentPage - 1}"><span aria-hidden="true">&laquo;</span></a>
			</li>
			<c:if test="${currentPage <= 4}">
				<c:forEach var="num" begin="0" end="${currentPage + 5 - currentPage}">
					<li class="${currentPage == num ? 'active' : ''}">
						<a href="./list.do?page=${num}">${num+1}</a>
					</li>
				</c:forEach>	
				<li><a>...</a></li>
				<li>
					
					<a href="./list.do?page=${total}">${total+1}</a>
				</li>	
			</c:if>
			<c:if test="${currentPage < total - 5 && currentPage > 4}">
			<li>
					
					<a href="./list.do?page=${0}">${1}</a>
				</li>
				<li><a>...</a></li>
				<c:forEach var="num" begin="${currentPage - 1}" end="${currentPage + 3}">
					<li class="${currentPage == num ? 'active' : ''}">
						<a href="./list.do?page=${num}">${num+1}</a>
					</li>
				</c:forEach>	
				<li><a>...</a></li>
				<li>
					
					<a href="./list.do?page=${total}">${total+1}</a>
				</li>	
				
			</c:if>
			<c:if test="${currentPage >= total - 5}">
			<li>
					
					<a href="./list.do?page=${0}">${1}</a>
				</li>
				<li><a>...</a></li>
				<c:forEach var="num" begin="${currentPage -(5 - (total - currentPage))}" end="${total}">
					<li class="${currentPage == num ? 'active' : ''}">
						<a href="./list.do?page=${num}">${num+1}</a>
					</li>
				</c:forEach>	
			
			</c:if>

		    <li  class="${currentPage == total ? 'disabled' : ''}">
				<a href="./list.do?page=${currentPage + 1}"><span aria-hidden="true">&raquo;</span></a>
			</li>
		</ul>
</body>
</html>